<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"  prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>查询商品列表</title>
	<script type="application/javascript" src="/resources/pic/jquery-1.12.0.min.js"></script>
	<script type="application/javascript" >
		$(function () {
			$.ajax({
			    type:"POST",
			  url:"/userRent?id=${user.userId}",
				success: function(data) {
			      for (var i = 0;i<data.length;i++){
                      $("#user_rent").append(data[i].bookName+","+" ")
                  }
                },
				dataType:"json"
			})
        })

		$(function () {
			$("")
        })
	</script>
</head>
<body>
<div>
	<c:if test="${user.userName!=null}">
		<p>欢迎您:${user.userName}</p>
		<p id = "user_rent">您当前共借阅图书:</p>
	</c:if>

	<c:if test="${user.userName==null}">
	<jsp:forward page="error.jsp"></jsp:forward>
	</c:if>


</div>

<form action="/bookQuery" method="post">
	<lable for="queryDesc">查询条件：</lable>
	<input type="text" name="queryDesc" id="queryDesc"/><br/>

<table width="100%" border=1>
<tr>
<td><input type="submit" value="查询"/></td>
</tr>
</table>
</form>



图书列表：
<form  action="/deletes" method="post">
<table width="100%" border=1>
<tr>
	<td><input type="checkbox" name="ids" value=""></td>
	<td>图书名称</td>
	<td>图书创建时间</td>
	<td>图书最新借走时间</td>
	<td>图书状态</td>
	<td>图书数量</td>
	<td>图书类型</td>
</tr>
<c:forEach items="${bookResult.rows}" var="book">
<tr>
	<td>${book.booId }</td>
	<td>${book.bookName }</td>
	<td><fmt:formatDate value="${book.bookCreatetime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
	<td><fmt:formatDate value="${book.bookRenttime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>

	<td>${book.bookStatus }</td>
	<td>${book.bookNumber }</td>
	<td>${book.bookType}</td>

	<c:if test="${book.bookStatus==0}">
		<td><a href="/rent?bookId=${book.booId}&userId=${user.userId}">借阅</a></td>
	</c:if>

	<c:if test="${book.bookStatus==1}">
		<td><a href="javascript:void(0)"  >借阅</a></td>
	</c:if>

</tr>
</c:forEach>

</table>

	共 ${pagesize}页 当前 第${page}页
	<c:choose>
		<c:when test="${page>1}">
			<a href="/bookList?page=${page-1}&rows=3"><input type="button" value="上一页" ></a>
		</c:when>
		<c:otherwise>
			<input type="button" value="上一页"  disabled="disabled" />
		</c:otherwise>
	</c:choose>

	<c:choose>
		<c:when test="${page!=pagesize}">
			<a href="/bookList?page=${page+1}&rows=3"><input type="button" value="下一页"></a>
		</c:when>
		<c:otherwise>
			<input type="button" value="下一页" disabled="disabled" />
		</c:otherwise>
	</c:choose>

	<input type="submit" value="删除">
</form>
</body>

</html>